define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'wk/teacher/index' + location.search,
                    add_url: 'wk/teacher/add',
                    edit_url: 'wk/teacher/edit',
                    del_url: 'wk/teacher/del',
                    multi_url: 'wk/teacher/multi',
                    import_url: 'wk/teacher/import',
                    table: 'wk_teacher',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'label_list', title: __('Label_list'), searchList: {"公考":__('公考'),"行测":__('行测'),"申论":__('申论'),"面试":__('面试'),"常识":__('常识'),"数量":__('数量'),"资料":__('资料'),"言语":__('言语'),"逻辑":__('逻辑')}, operate:'FIND_IN_SET', formatter: Table.api.formatter.label},
                        {field: 'head_image', title: __('Head_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'status', title: __('Status'), searchList: {"30":__('Status 30')}, formatter: Table.api.formatter.status},
                        {field: 'operate',   buttons: [
                                {
                                    name: "comment",
                                    title: "评论",
                                    text: "",
                                    classname: "btn btn-xs btn-primary btn-dialog",
                                    icon: "fa fa-list-ol",
                                    url: 'wk/Comment/index?teacher_id={ids}',
                                },
                            ],title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
